%% Parameters for the fiscal model
% estimated parameters are noted as '(est)'

%% FISCAL PARAMETERS
% Fiscal rule
p.f1           = 0.5; % automatic stabilizer
p.f2           = 0.1; % government sensitivity to the deviation from the target debt

% Structural deficit rule
p.ss_f3        = 0.8; % stiffness of structural deficit
p.f4           = 0;   % pro-/counter-cyclicality in structural deficit

% Fiscal impulse
p.g1           = 0.4; % pass-through from change in debt target (shock) to fiscal impulse   

%% OTHER BUSINESS CYCLE PARAMETERS
% IS curve
p.k1           = 0.15;
p.k2           = 0.4;
p.k3           = 0.2;
p.k4           = 0.15;
p.k5           = 0.5;
p.k6           = 0.4;

% Phillips curve
p.e1           = 0.4;
p.e2           = 0.1;
p.e3           = 0.4;

% Monetary policy rule
p.u1           = 0.35;
p.u2           = 1.5;

%% LONG-TERM PARAMETERS (premiums to debt sensitivity)
p.p1           = 0.05; % 10pp of extra debt raises 3Y term premium by 50bp
p.p2           = 0.08; % 10pp of extra debt raises 10Y term premium by 80bp
p.p3           = 0.15; % 10pp increase of debt to gdp (30%->40%, for instance) depreciates the trend real exchange rate by 1.5%
p.p4           = 0.05; % 10pp increase of debt to gdp raises country premium by 50bp
p.p5           = 1.0;  % 1pp increase in long-term real interest rate lowers potential output by 1%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Shock correlation parameters
p.cor_p_y      = 0.2; % 1% of potential level is 0.2% cost-push
p.cor_y_g      = 0.5; % 1pp in potential growth is 0.5% of demand shock

%% Autoregressive parameters
p.rho_prem      = 0.7;
p.rho_tprem3    = 0.65;
p.rho_tprem10   = 0.75;

p.rho_g_z_tnd   = 0.9;
p.rho_g_y_tnd   = 0.9;

p.rho_dlp_wedge = 0.3;

p.rho_rrf_tnd   = 0.9160; % (est)
p.rho_rrf_gap   = 0.6252; % (est)
p.rho_y_eu_gap  = 0.5329; % (est)
p.rho_dl_p_eu   = 0.2839; % (est)

%% Steady-state parameters
p.ss_dl_p_eu    = 1.9;   % euro area inflation target
p.ss_rrf_tnd    = 0.7691;% world real interest rate (est)
p.ss_tprem3     = 0.70;  % term premium 3Y over 1Y
p.ss_tprem10    = 1.20;  % term premium 10Y over 1Y
p.ss_debt_rat   = 30;    % only for calibration of ss_tprem3, ss_tprem10, and ss_prem
p.ss_g_y_tnd    = 2;     % potential growth rate
p.ss_g_z_tnd    = -2.5;  % real exchange rate depreciation rate
p.ss_prem       = 2.5;   % country risk and currency premium

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Analytical steady-state
%%%%%%
p.l_y                       = complex(0, p.ss_g_y_tnd);
p.dl_y                      = p.ss_g_y_tnd;
p.l_y_tnd                   = complex(0, p.ss_g_y_tnd);
p.l_y_gap                   = 0;
p.g_y_tnd                   = p.ss_g_y_tnd;
p.dl_cpi_tar                = 2;
p.l_p                       = complex(0, p.dl_cpi_tar);                       
p.dl_p                      = p.dl_cpi_tar;
p.l_cpi                     = complex(0, p.dl_cpi_tar);                       
p.dl_cpi                    = p.dl_cpi_tar;
p.e_dl_cpi                  = p.dl_cpi_tar;
p.dl_cpi_imp                = p.dl_cpi_tar;
p.dl_ny                     = p.dl_cpi_tar+p.ss_g_y_tnd;
p.l_ny                      = complex(0, p.dl_ny);
p.e_dl_ny                   = p.dl_ny;
p.rr1                       = p.ss_g_z_tnd + p.ss_rrf_tnd + p.ss_prem;                       
p.rsg1                      = p.rr1 + p.dl_cpi_tar;
p.rsg1des                   = p.rr1 + p.dl_cpi_tar;
p.rsg3                      = p.rsg1 + p.ss_tprem3;
p.rsg10                     = p.rsg1 + p.ss_tprem10;
p.tprem3                    = p.ss_tprem3;
p.tprem10                   = p.ss_tprem10;
p.rr1_tnd                   = p.rr1;
p.rr3                       = p.rr1 + p.ss_tprem3;
p.rr10                      = p.rr1 + p.ss_tprem10;
p.rr3_tnd                   = p.rr1 + p.ss_tprem3;  
p.rr10_tnd                  = p.rr1 + p.ss_tprem10;
p.lrr                       = 0.4*p.rr1 + 0.4*p.rr3 + 0.2*p.rr10;
p.lrr_tnd                   = p.lrr;
p.d_lrr_tnd                 = 0;
if p.premrsgfcy_is_rw == true
  p.prem_rsg_fcy              = 0; 
else
  p.prem_rsg_fcy              = p.ss_prem; 
end
p.rsg_fcy                   = p.ss_rrf_tnd + p.ss_dl_p_eu + p.prem_rsg_fcy + 5/7*p.ss_tprem3 + 2/7*p.ss_tprem10;
p.dl_czk_eur                = p.ss_g_z_tnd + p.dl_cpi_tar - p.ss_dl_p_eu;
p.l_czk_eur                 = complex(0, p.dl_czk_eur);

p.debt_rat                  = p.ss_debt_rat;                  
p.debt_tar_rat              = p.ss_debt_rat;
p.e_debt_dev                = 0;
p.def_rat                   = p.ss_debt_rat*(1-1/exp(p.dl_ny/100));
p.def_struct_rat            = p.def_rat;
p.def_struct_tar_rat        = p.def_rat;
p.cycle_gap                 = 0;
p.f3                        = p.ss_f3;
p.fiscimp_rat               = 0;
p.share1_def                = 0.3;
p.share3_def                = 0.3;
p.share10_def               = 0.3;
p.share_fcy                 = 1-p.share1_def-p.share3_def-p.share10_def;
p.debt1_rat                 = p.share1_def*p.def_rat/(1-1/exp(p.dl_ny/100));
p.debt3_rat                 = p.share3_def*p.def_rat/(1-1/exp(3*p.dl_ny/100));
p.debt10_rat                = p.share10_def*p.def_rat/(1-1/exp(10*p.dl_ny/100));
p.debt_fcy_rat              = p.share_fcy*p.def_rat/(1-exp(5*(p.dl_czk_eur-p.dl_ny)/100));
p.totdebt1_rat              = p.debt1_rat;
p.totdebt3_rat              = p.debt3_rat*(1+exp(-p.dl_ny/100)+exp(-2*p.dl_ny/100));
p.totdebt10_rat             = p.debt10_rat*(1+exp(-p.dl_ny/100)+exp(-2*p.dl_ny/100)+exp(-3*p.dl_ny/100)+exp(-4*p.dl_ny/100)+exp(-5*p.dl_ny/100)+exp(-6*p.dl_ny/100)+exp(-7*p.dl_ny/100)+exp(-8*p.dl_ny/100)+exp(-9*p.dl_ny/100));
p.intcost1_rat              = p.debt1_rat*(exp(p.rsg1/100)-1)*exp(-p.dl_ny/100);
p.intcost3_rat              = p.debt3_rat*(exp(p.rsg3/100)-1)*(exp(-p.dl_ny/100)+exp(-2*p.dl_ny/100)+exp(-3*p.dl_ny/100));
p.intcost10_rat             = p.debt10_rat*(exp(p.rsg10/100)-1)*(exp(-p.dl_ny/100)+exp(-2*p.dl_ny/100)+exp(-3*p.dl_ny/100)+exp(-4*p.dl_ny/100)+exp(-5*p.dl_ny/100)+exp(-6*p.dl_ny/100)+exp(-7*p.dl_ny/100)+exp(-8*p.dl_ny/100)+exp(-9*p.dl_ny/100)+exp(-10*p.dl_ny/100));
p.intcost_fcy_rat           = p.debt_fcy_rat*(exp(p.rsg_fcy/100)-1)*(exp((p.dl_czk_eur-p.dl_ny)/100)+exp(2*(p.dl_czk_eur-p.dl_ny)/100)+exp(3*(p.dl_czk_eur-p.dl_ny)/100)+exp(4*(p.dl_czk_eur-p.dl_ny)/100)+exp(5*(p.dl_czk_eur-p.dl_ny)/100));
p.intcost_rat               = p.intcost1_rat + p.intcost3_rat + p.intcost10_rat + p.intcost_fcy_rat;
p.primdef_rat               = p.def_rat - p.intcost_rat;
  
p.rsf                       = p.ss_rrf_tnd + p.ss_dl_p_eu;
p.rrf                       = p.ss_rrf_tnd;
p.rrf_gap                   = 0;
p.l_y_eu_gap                = 0;
p.dl_p_eu                   = p.ss_dl_p_eu;
p.l_p_eu                    = complex(0,p.dl_p_eu);
p.rrf_tnd                   = p.ss_rrf_tnd;
p.prem                      = p.ss_prem;
p.l_z                       = complex(0,p.ss_g_z_tnd);
p.l_z_tnd                   = p.l_z;
p.g_z_tnd                   = p.ss_g_z_tnd;
p.l_z_gap                   = 0;